#!/usr/bin/env node

import degit from "degit";

// 获取命令行参数
const args = process.argv.slice(2);
const [repo, branch = "main"] = args;

if (!repo) {
  console.error("Please specify a repository to clone.");
  process.exit(1);
}

const emitter = degit(`${repo}#${branch}`, {
  cache: false,
  force: true,
  verbose: true,
});

emitter.on("info", (info) => {
  console.log(info.message);
});

emitter
  .clone(`./${repo.split("/")[1]}`)
  .then(() => {
    console.log("Cloned successfully.");
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });
